#include<iostream>
#include"BinarySearchTree.h"
#include<time.h>
#include<fstream>

int main()
{
	std::cout<<"-----START-----"<<std::endl;
	std::vector<int> a = {5,4,2,3,1,6};
	BSTsorting(a,1);
	ofstream fout;
	fout.open("/mnt/c/Users/Lenovo/Desktop/testdata.txt");
		int perm = 100;
		std::vector<int> chr(1000000);
		clock_t s1,e1;
		clock_t s2,e2;
	for(int i = 1;i<6;i++)
	{
		int num = std::pow(10,i);
		for(int i = 0;i<num;i++)
		{
			chr.push_back(i+1);
		}
		//test time complexity
		//normal mode
		s1 = clock();
		BSTsorting(chr,0);
		e1 = clock();
	
	
		//random mode
		double sumt = 0;
		double t_bar = 0;
		for(int k = 0;k<perm;k++)
		{
			s2 = clock();
			BSTsorting(chr,1);
			e2 = clock();
			sumt+=double(e2-s2)/CLOCKS_PER_SEC;
			chr.clear();
			for(int i = 0;i<num;i++)
			{
				chr.push_back(i+1);
			}
			random_shuffle(chr.begin(),chr.end());
		}

		t_bar=sumt/perm;
		//std::cout<<"Time for "<<num<<" nodes in Normal mode is: "<<double(e1-s1)/CLOCKS_PER_SEC<<" ";
		//std::cout<<"Time for "<<num<<" nodes in Random mode is: "<<t_bar<<std::endl;
		fout<<double(e1-s1)/CLOCKS_PER_SEC<<"\t";
		fout<<t_bar<<std::endl;

	}
	return 0;
}
